package com.wo2record.blog.service.impl;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.wo2record.base.service.impl.BaseServiceAbstractImpl;
import com.wo2record.base.util.ModelUtil;
import com.wo2record.blog.model.ArticleTag;
import com.wo2record.blog.service.ArticleTagService;

public class ArticleTagServiceImpl extends BaseServiceAbstractImpl<ArticleTag> implements
		ArticleTagService {

	@Override
	public Class<?> getObjectClass() {
		return ArticleTag.class;
	}

	@Override
	public void validateObjectBeforeSave(ArticleTag t) throws Exception {
		
	}
	
	@Transactional
	public Boolean isTagExist(ArticleTag articleTag){
		List<ArticleTag> articleTags = getObjects("from " + ArticleTag.class.getName() + " where tag = '" + articleTag.getTag() + "'");
		return !ModelUtil.isBlank(articleTags);
	}

}
